package com.ggh.handler;
import com.ggh.entity.*;
import com.ggh.service.RoomWinRecordService;
import com.ggh.service.UserRecordService;
import com.ggh.service.impl.RoomWinRecordServiceImpl;
import com.ggh.service.impl.UserRecordServiceImpl;
import com.ggh.service.impl.UserServiceImpl;
import com.ggh.service.UserService;
import com.ggh.util.ApplicationContextProvider;
import com.ggh.util.JsonUtils;
import com.ggh.websocket.PK_WebSocket_P;
import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * @author Administrator
 */
@Slf4j
public class RobBanker_TimeP extends Thread {
	private Map<String, Object> map = new HashMap<>();


	Gson gson = JsonUtils.get();
	// -----------------
	/**
	 * 战绩添加
	 */
	private UserRecordService userRecordService;
		/**
		 * 房间类
		 */
	private RoomBeanP room;
		/**
		 * 时间
		 */
	private int timer;
	/**
	 * 用户逻辑
	 */
	private UserService userService;
	/**
	 * AI机器人
	 */
	private AiHandler aiHandler;
	/**
	 * 近几局的输赢记录
	 */
	private RoomWinRecordService roomWinRecordService;
	/**
	 * 算法逻辑类
	 */
	private BeginToJudgePKC pkp=new BeginToJudgePKC();

	/**
	* @description :倒计时
	* @param room
	* @return: null
	* @date : 2019/10/8 15:28
	* @author : jj
	* @throws
	*/
	public RobBanker_TimeP(RoomBeanP room) {
		this.room = room;
		this.userRecordService= ApplicationContextProvider.getBean(UserRecordServiceImpl.class);
		this.userService= ApplicationContextProvider.getBean(UserServiceImpl.class);
		this.aiHandler=ApplicationContextProvider.getBean(AiHandler.class);
		this.roomWinRecordService=ApplicationContextProvider.getBean(RoomWinRecordServiceImpl.class);
	}

	@Override
	public void run() {
		while (true) {
			/*
			 * 房间状态
			 * 0等待加入
			 * 1、准备倒计时
			 * 2、下注状态
			 * 3、下注结束
			 * 4、客户端发送
			 *  5、开始发牌
			 *  6、提示并组牌
			 *  7、已结算
			 *  8、开始下一句
			 */
			if (room == null || room.getState() != 1  && room.getState() != 6
					&& room.getState() != 7 && room.getState() != 8&& room.getState() != 5&&room.getState()!=3&&room.getState()!=2&&room.getState() !=4) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				continue;
			}
			/**
			 * @description :判断房间是否解散
			 * @return: void
			 * @date : 2019/10/8 15:34
			 * @author : jj
			 * @throws
			 */
			if (room.getExit_game() == 1 || room.getExit_game() == 2) {
				try {
					Thread.sleep(1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				continue;
			}

			/**
			 * 对房间状态进行轮询监听
			 */
			timer = room.getTime();
			System.out.println("-------------------------时间timer：" + timer);
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			timer--;
			System.out.println("time：" + timer);
			// 时间存入房间
			room.setTime(timer);
			/**
			 * @description :准备状态状态时，判断用户的选择情况
			 * @return: void
			 * @date : 2019/10/8 15:35
			 * @author : jj
			 * @throws
			 */
			try {
				if (room.getState() == 1 && timer > 0 && room.getExit_game() != 1) {
					zbdjs();
				}

				/**@description :准备倒计时结束*/
				if (timer == 0 && room.getState() == 1 && room.getExit_game() != 1) {
					map.clear();
					if (room.getExit_game() == 1 || room.getExit_game() == 2) {
						room.setTime(room.getTime() + 1);
						continue;
					}
					zbdjsjs();
				}


				/**@description :下注状态时，判断用户的选择情况*/
				if (room.getState() == 2 && timer > 0 && room.getExit_game() != 1) {
					map.clear();
					xzdjs();
				}

				/**@description :下注结束*/
				if (timer == 0 && room.getState() == 2  && room.getExit_game() != 1) {
					map.clear();
					xzjs();
					System.out.println("下注结束-------------");
				}
				/*延迟*/
				if (room.getState()==4&&timer==0){
					room.setState(5);
				}
				/** @description :开始发牌*/
				if (room.getState() == 5 && room.getExit_game() != 1){
					map.clear();
					deal();
				}

				/* @description :用户进行组牌*/
				if (room.getState()==6&&timer>0){
					map.clear();
					tipsorzupai();
				}

				/* @description :百人大牌九比牌*/
				if (timer == 0 && room.getState() == 6 && room.getGame_type() ==0) {
					map.clear();
					bipai();
				}

				/*@description  结算*/
				if (room.getState() == 7 ) {
					map.clear();
					//方法
					jiesuan();
				}

				/* 比牌结束 ，开始下一局*/
				if (room.getState() == 8 && room.getExit_game() != 1) {
					map.clear();
					jsorxyj();
				}
			}catch (Exception e){
				System.err.println(e.getMessage());
				log.info("错误日志："+e.getMessage());
				room.setState(0);
				e.printStackTrace();
			}


		}
	}

//-----------------------方法区------------------------



	/**
	 * @description :准备倒计时
	 * @return: void
	 * @date : 2019/10/10 10:52
	 * @author : jj
	 * @throws
	 */
	private  void zbdjs(){

		if (room.getGame_userlist().size()>2) {
			// 循环判断观战人数
			for (int i = 0; i < room.getGame_userlist().size(); i++) {

				 /*查询用户*/
				UserBean u =  room.getGame_userlist().get(i);
				if (u.getIsAi()==1&&u.getBanker()!=2){
					aiHandler.judge(room,u,1);
				}
				if (u.getIsAi()==1&&u.getBanker()==2){
					aiHandler.judge(room,u,2);
				}
				/*用户退出或者掉线*/
				if (u.getExit_state() == 1 || u.getReady_state() == 2) {
					u.userEmpty();
					room.getGame_userlist().remove(i);
					if (room.getUpbanker().contains(u.getUserid())){
					    room.getUpbanker().remove(u.getUserid());
                    }
					//如果是庄家
					if (u.getUserid()==room.getBanker()){
						room.setBanker(0);
						room.setZMoney(0);
						room.setKMoney(0);
					}
					//数组队列清楚
					for (int j=0;j<room.getUser_positions().length;j++){
					    if (room.getUser_positions()[i]==u.getUserid()){
					        room.getUser_positions()[i] =-1;
                        }
                    }
				}
				/*中途加入*/
				if (u.getReady_state() == 4 || u.getReady_state() == 0) {
					u.setReady_state(1);
					u.setBanker(1);
				}
			}
			//庄家连坐24局
			if (room.getUserBean(room.getBanker())!=null){
				UserBean userBean = room.getUserBean(room.getBanker());
				if (userBean.getDowbanker()>23){
					userBean.setBanker(1);
					room.setBanker(0);
					fixedBanker();
				}
				//庄家赢8倍
				if (room.getZMoney()>room.getUserBean(room.getBanker()).getDqnumber()*8){
					userBean.setBanker(1);
					room.setBanker(0);
					fixedBanker();
				}
				//低于10%
				if (room.getZMoney()<room.getUserBean(room.getBanker()).getDqnumber()*0.1){
					userBean.setBanker(1);
					room.setBanker(0);
					fixedBanker();
				}
			}
			//没有庄家的情况
			if (room.getBanker() == 0) {
				fixedBanker();
			}
		}else {
			room.setState(0);
		}
	}
	/**
	 * @description :准备倒计时结束
	 * @return: void
	 * @date : 2019/10/9 10:57
	 * @author : jj
	 * @throws
	 */
	private void zbdjsjs(){
		/*临时添加*/
		if(room.getUpbanker().size()>0){
			room.setBanker(room.getUpbanker().get(0));
			UserBean userBean = room.getUserBean(room.getUpbanker().get(0));
			userBean.setBanker(2);
			room.setZMoney(userBean.getDqnumber());
			room.setKMoney(userBean.getDqnumber());
			room.getUpbanker().remove(0);

		}
		map.put("type", TypeBean.BaiRenGameInciDent);
		map.put("messages",gson.toJson(room));
		sendMessageAll(map, room);
		// 第一局游戏开始，修改对局数
		if (room.getGame_number() == 0 || room.getGame_number() == 1) {
			room.setGame_number(1);
		}
		/*
		 * 修改状态
		 * */
		room.setState(2);
		room.setTime(room.getTime02());
		timer=room.getTime();
		map.put("type", TypeBean.BaiRenGameInciDent);
		map.put("messages",gson.toJson(room));
		sendMessageAll(map, room);

	}
	/**
	 * @description :下注倒计时
	 * @return: void
	 * @date : 2019/10/9 10:45
	 * @author : jj
	 * @throws
	 */
	private void xzdjs(){
		// 房间人数
		int a = 0;
		// 下注人数
		int b = 0;
		/*循环判断该下注人数*/
		for (int i = 0; i <room.getGame_userlist().size(); i++) {
			UserBean u = room.getGame_userlist().get(i);
            Random rand = new Random();
			if (u.getIsAi()==1&&timer%(rand.nextInt(3)+1)==0){
				aiHandler.judge(room,u,3);
			}
			a++;
			if (1 == u.getPower_type()) {
				b++;
			}
		}
		System.out.println("在座a：" + a + ",选择b：" + b);
		if (room.getKMoney() == 0) {
			//下注提前结束
			room.setTime(0);
			timer = 0;
			System.out.println("房间时间" + room.getTime());
		}
	}
	/**
	 * @description :下注结束
	 * @return: void
	 * @date : 2019/10/9 10:42
	 * @author : jj
	 * @throws
	 */
	private void xzjs(){
		room.setState(3);
		int num1 = (int) (Math.random() * 6);
		int num2 = (int) (Math.random() * 6);
		int[] saizhi ={num1,num2};
		room.setSaizhi(saizhi);
		map.clear();
		map.put("type",TypeBean.BaiRenGameInciDent);
		map.put("messages", gson.toJson(room));
		sendMessageAll(map,room);
		room.setState(4);
		//延迟导致
		room.setTime(5);
		timer=room.getTime();
	}
	/**
	 * @description :开始发牌
	 * @return: void
	 * @date : 2019/10/9 10:39
	 * @author : jj
	 * @throws
	 */
	private void deal() {
		//发牌
		room.dealBranch();
		/*判断是百人大还是小*/
		if (room.getGame_type() == 1) {
			/* 比牌*/
			bp();

			/* 发送消息*/
			map.put("type", TypeBean.BaiRenGameInciDent);
			map.put("messages", gson.toJson(room));
			sendMessageAll(map, room);
			/**
			 * 进行休眠
			 */
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			//修改状态
			room.setState(7);
		}else {
			/*
			 * 发送消息
			 */
			map.put("type", TypeBean.BaiRenGameInciDent);
			map.put("messages", gson.toJson(room));
			sendMessageAll(map, room);
			/* 添加倒计时  修改状态*/
			room.setTime(room.getTime02());
			timer=room.getTime();
			room.setState(6);
		}

	}
	/**
	 * @description :进行比牌
	 * @return: void
	 * @date : 2019/10/9 15:47
	 * @author : jj
	 * @throws
	 */
	private void bp(){
		int i1 = pkp.contrast(room, room.getZpai(), room.getCpai());
		room.setChuWin(i1);
		int i2 = pkp.contrast(room, room.getZpai(), room.getTpai());
		room.setTianWin(i2);
		int i3 = pkp.contrast(room, room.getZpai(), room.getMpai());
		room.setMoWin(i3);
	}
	/**
	 * @description :个人结算
	 * @return: void
	 * @date : 2019/10/9 15:54
	 * @author : jj
	 * @throws
	 */
	private void grjs(){
		//获取用户
		UserBean uz = room.getUserBean(room.getBanker());
		float uzMoney=uz.getMoney();
		for (int i = 0; i <room.getGame_userlist().size(); i++) {
			UserBean ux = room.getGame_userlist().get(i);
			float uxMoney= ux.getMoney();
			/*
			 *判断那个桌子输赢
			 */
			if (room.getChuWin()==1){
				ux.setMoney(ux.getMoney()+(ux.getChu()*2));
				uz.setMoney(uz.getMoney()-ux.getChu());
				ux.setChu(ux.getChu()*2);
			}else {
				uz.setMoney(uz.getMoney()+ux.getChu());
				ux.setChu(-ux.getChu());
			}
			if (room.getTianWin()==1){
				ux.setMoney(ux.getMoney()+(ux.getTian()*2));
				uz.setMoney(uz.getMoney()-ux.getTian());
				ux.setTian(ux.getTian()*2);
			}else {
				uz.setMoney(uz.getMoney()+ux.getTian());
				ux.setTian(-ux.getTian());
			}
			if (room.getMoWin()==1){
				ux.setMoney(ux.getMoney() + (ux.getMo()*2));
				uz.setMoney(uz.getMoney() - ux.getMo());
				ux.setMo(ux.getMo()*2);
			}else {
				uz.setMoney(uz.getMoney() + ux.getMo());
				ux.setMo(-ux.getMo());
			}
			//判断亏损
			ux.setNumber((ux.getMoney()-uxMoney));
			if ((ux.getMoney()-uxMoney)>0){
				ux.setHu_state(1);
				User us=userService.getById(ux.getUserid());
				if (us!=null){
					us.setMoney(ux.getMoney()-(float)(uz.getMoney()*0.05));
					userService.updateById(us);
				}
			}else {
				ux.setHu_state(0);
			}

		}
		//判断亏损
		uz.setNumber(uz.getMoney()-uzMoney);
		if ((uz.getMoney()-uzMoney)>0){
			uz.setHu_state(1);
			User ur = userService.getById(uz.getUserid());
			if (ur!=null){
				ur.setMoney(uz.getMoney()-(float)(uz.getMoney()*0.05));
				userService.updateById(ur);

			}
		}else {
			uz.setHu_state(0);
		}
	}
	/**
	 * @description :总积分结算
	 * @return: void
	 * @date : 2019/10/9 15:56
	 * @author : jj
	 * @throws
	 */
	private void zjfjs(){
		if (room.getChuWin()==1){
			room.setZMoney(room.getZMoney()-room.getChuMoney());
		}else {
			room.setZMoney(room.getZMoney()+room.getChuMoney());
		}
		if (room.getTianWin()==1){
			room.setZMoney(room.getZMoney()-room.getTianMoney());
		}else {
			room.setZMoney(room.getZMoney()+room.getTianMoney());
		}
		if (room.getMoWin()==1){
			room.setZMoney(room.getZMoney()-room.getMoMoney());
		}else {
			room.setZMoney(room.getZMoney()+room.getMoMoney());
		}
		System.out.println(room.getZMoney()+"###################################)))))))))))))))");
	}

	/**
	 * @description :房间内的没有组牌的进行组牌
	 * @return: void
	 * @date : 2019/10/9 10:12
	 * @author : jj
	 * @throws
	 */
	private void roomzhupai(){
		for (int i = 0; i < room.getGame_userlist().size(); i++) {
			// 获取用户信息
			UserBean u =room.getGame_userlist().get(i);
			/**
			 * 判断是否自己组牌
			 */
			if (u.getPower_type() == 2 || u.getReady_state() == 4 || u.getBrands().size() < 1) {
				continue;
			}

			/**
			 *  给重新组的桌子组牌
			 */
			if (u.getIsbrand()==1&&u.getPower_type()!=2){
				List<Integer> tips = pkp.tips(room.getCpai());
				System.out.println(
						"返回：" + tips.get(0) + "-" + tips.get(1) + ",排序前-------------" +room.getCpai().get(0) + ":"
								+ room.getCpai().get(1) + ":" + room.getCpai().get(2) + ":" + room.getCpai().get(3));

				/**
				 * 调换位置
				 */
				room.getCpai().clear();
				room.setCpai(tips);
			}
			if (u.getIsbrand()==2&&u.getPower_type()!=2){
				List<Integer> tips = pkp.tips(room.getTpai());
				System.out.println(
						"返回：" + tips.get(0) + "-" + tips.get(1) + ",排序前-------------" +room.getTpai().get(0) + ":"
								+ room.getTpai().get(1) + ":" + room.getTpai().get(2) + ":" + room.getTpai().get(3));

				/**
				 * 调换位置
				 */
				room.getTpai().clear();
				room.setTpai(tips);
			}
			if (u.getIsbrand()==3&&u.getPower_type()!=2){
				List<Integer> tips = pkp.tips(room.getMpai());
				System.out.println(
						"返回：" + tips.get(0) + "-" + tips.get(1) + ",排序前-------------" +room.getMpai().get(0) + ":"
								+ room.getMpai().get(1) + ":" + room.getMpai().get(2) + ":" + room.getMpai().get(3));

				/**
				 * 调换位置
				 */
				room.getMpai().clear();
				room.setMpai(tips);
			}
			if (u.getBanker()==2&&u.getPower_type()!=2){
				List<Integer> tips = pkp.tips(room.getZpai());
				System.out.println(
						"返回：" + tips.get(0) + "-" + tips.get(1) + ",排序前-------------" +room.getZpai().get(0) + ":"
								+ room.getZpai().get(1) + ":" + room.getZpai().get(2) + ":" + room.getZpai().get(3));

				/**
				 * 调换位置
				 */
				room.getZpai().clear();
				room.setZpai(tips);
			}

		}
	}
	/**
	 * @description :提示或者组牌
	 * @return: void
	 * @date : 2019/10/9 10:35
	 * @author : jj
	 * @throws
	 */
	private void tipsorzupai() {
		// 房间人数
		int a = 0;
		// 组牌人数
		int b = 0;
		for (int i = 0; i <room.getGame_userlist().size(); i++) {
			UserBean u =room.getGame_userlist().get(i);
			a++;
			if (2 == u.getPower_type()) {
				b++;
			}
		}
		if (4==b){
			room.setTime(0);
			timer =0;
		}
	}
	/**
	 * @description :用户比牌
	 * @return: void
	 * @date : 2019/10/9 10:21
	 * @author : jj
	 * @throws
	 */
	private void bipai(){

		/*提醒扣牌*/
		map.put("type", "BaiRenLargeKouPaiAll");
		sendMessageAll(map,room);
		/*等待3秒*/
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		//对房间内没有组牌进行组牌
		roomzhupai();
		// 组牌结束，进行比牌---------
		System.out.println("结算中-------------");
		/* 进行比牌*/
		bp();
		/*发送消息*/
		map.put("type", TypeBean.BaiRenGameInciDent);
		map.put("messages", gson.toJson(room));
		sendMessageAll(map,room);
		//修改状态临时修改
		room.setState(7);
	}
	/**
	 * @description :房间结算
	 * @return: void
	 * @date : 2019/10/9 10:24
	 * @author : jj
	 * @throws
	 */
	private void jiesuan(){
		// 结算
		if (room.getChuWin() == 0&&room.getTianWin() ==0 &&room.getMoWin()==0) {
			// 通杀加倍
			room.setHint(1);
		}
		/* 结算个人 */
		grjs();
		/* 总积分结算*/
		zjfjs();
		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		/*发送消息*/
		map.put("type", TypeBean.BaiRenGameInciDent);
		map.put("messages", gson.toJson(room));
		sendMessageAll(map, room);
		room.setState(8);
		/**
		 * 进行休眠
		 */
		try {
			Thread.sleep(6000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	/**
	 * @description :结束游戏或者开启下一局
	 * @return: void
	 * @date : 2019/10/9 10:32
	 * @author : jj
	 * @throws
	 */
	private void jsorxyj(){
		// 循环所有用户，存入战绩信息
		for (int i = 0; i < room.getGame_userlist().size(); i++) {
			UserBean us = room.getGame_userlist().get(i);
			if (us.getReady_state() == 4) {
				continue;
			}
			if (us.getLog_lat() == -1) {
				continue;
			}
			if (us.getBanker() == 2) {
				us.setBanker(1);
			}
		}
		// 循环所有用户，存入战绩信息
		userRecordService.addList(room);
		/**
		 * 添加房间输赢记录
		 */
		 roomWinRecordService.add(room);
		// 添加房间对局数
		room.setGame_number(room.getGame_number() + 1);
		// 所有用户添加对局数
		for (int j = 0; j < room.getGame_userlist().size(); j++) {
			UserBean u = room.getGame_userlist().get(j);
			u.Initialization();

			if ( u.getReady_state() == 4) {
				u.setReady_state(1);
				u.setBanker(1);
			}
			/*判断是否有没有坐下的人员，并坐下*/
			for (int i = 0; i < room.getGame_userlist().size(); i++) {
				if (room.getGame_userlist().get(i).getUserid()!=room.getUser_positions()[i]&&room.getUser_positions()[i] ==-1){
					room.getUser_positions()[i] = u.getUserid();
					u.setLog_lat(i);
				}
			}
		}
		// 判断对局是否结束
		if (room.getGame_userlist().size() <2) {
			// 提示游戏结束
			room.setState(10);
			map.put("messages", "对局结束...");
			// 返回结果
			map.put("type", TypeBean.BaiRenGameInciDent);
		} else {
			UserBean userBean = room.getUserBean(room.getBanker());
			userBean.setDowbanker(userBean.getDowbanker()+1);
			// 初始化房间信息
			room.Initialization();
			// 有2个人准备（坐下）,修改房间状态
			room.setState(1);
			// 赋值房间时间.房间今日准备倒计时
			room.setTime(room.getTime01());
			map.put("type", TypeBean.BaiRenGameInciDent);
			map.put("messages", gson.toJson(room));
		}
		timer = room.getTime();
		//发送消息
		sendMessageAll(map, room);
		if (room.getState() == 10) {
			// 删除数据库中房间信息(改状态为结束)
			room.setState(0);
		}
	}

	/**
	 * @description :随机定庄
	 * @return: bean.UserBean
	 * @date : 2019/10/7 15:13
	 * @author : jj
	 * @throws
	 */
	public void fixedBanker() {
		UserBean user;
		// 判断抢庄人数
		System.out.println("抢庄人数"+room.getUpbanker().size() );
		if (room.getUpbanker().size() > 0) {
			// 获取指定的庄家的id
			int userid = room.getUpbanker().get(0);
			System.out.println("庄家id：" + userid);
			// 获取指定庄家用户信息
			user = room.getUserBean(userid);
			room.getUpbanker().remove(0);
			// 没人抢庄
		} else {
			// 指定庄家
			List<Integer> list = new ArrayList<Integer>();
			// 指定庄家
			List<Integer> ailist = new ArrayList<Integer>();
			for (int i = 0; i < room.getGame_userlist().size(); i++) {
				// 获取用户信息
				UserBean u =room.getGame_userlist().get(i);
				if (u.getIsAi()==1){
					ailist.add(u.getUserid());
				}else {
                    list.add(u.getUserid());
                }



			}
			int userid;
			/*首先查找机器人*/
			if (ailist.size()>0){
				int random = (int) (Math.random() * ailist.size());
				// 获取指定的庄家的id
				 userid = ailist.get(random);
				System.out.println("庄家id：" + userid);
			}else {
				int random = (int) (Math.random() * (list.size()-1));
				// 获取指定的庄家的id
				 userid = list.get(random);
				System.out.println("庄家id：" + userid);

			}
			// 获取指定庄家用户信息
			user = room.getUserBean(userid);
		}
		// 用户标识改为庄家
		user.setBanker(2);
		// 添加房间庄家
		room.setBanker(user.getUserid());
		if (user.getDqnumber()==0){
			user.setDqnumber(5000);
			room.setZMoney(5000);
		}else {
			room.setZMoney(user.getDqnumber());
		}
		room.setKMoney((int) room.getZMoney());
	}

	/**
	 * @description :发送消息给所有人
	 * @param returnMap
	 * @param rb
	 * @return: void
	 * @date : 2019/10/8 15:36
	 * @author : jj
	 * @throws
	 */
	public synchronized void sendMessageAll(Map<String, Object> returnMap, RoomBeanP rb) {
		for (UserBean userb : rb.getGame_userlist()) {
			PK_WebSocket_P webSocket = Public_State_P.clients.get(String.valueOf(userb.getUserid()));
			if (webSocket != null && webSocket.getSession().isOpen() && userb.getExit_state() == 0) {
				// 不等于自己的则发送消息
				webSocket.sendMessageTo(returnMap, userb);
			} else {
				continue;
			}
		}
	}

}
